package com.liliya.utils;

import java.io.File;
import java.util.Random;

/**
 * @Description 获得路径下面的随机图片
 * @Author hhy
 * @Date 2021/1/8 17:49
 */
public class RandomFile {
    public String getFileName(String path){
        String fileName = "";
        File file = new File(path);
        if (file.isDirectory()&&file.exists()){
            File[] files = file.listFiles();
            int num = new Random().nextInt(files.length-1);
            fileName = files[num].getName();
        }

        return fileName;
    }
}
